package cz.cvut.fel.gfupan.gui;

import cz.cvut.fel.gfupan.gui.action.DemoAction;
import cz.cvut.fel.gfupan.gui.action.NewAction;
import cz.cvut.fel.gfupan.gui.action.OpenAction;
import java.awt.Frame;

public class StartupWindow extends javax.swing.JDialog {

    private Frame parent;

    public StartupWindow(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.parent = parent;
        initComponents();

        setActionListeners();

        setLocationRelativeTo(null);
        this.parent.setEnabled(false);
    }

    private void setActionListeners() {
        newItem.addActionListener(new NewAction(this));
//        demoItem.addActionListener(new DemoAction(this));
        openItem.addActionListener(new OpenAction(this));
    }
    
    //overloaded dispose method which actives parent's Frame
    @Override
    public void dispose() {
        this.parent.setEnabled(true);
        super.dispose();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        newItem = new javax.swing.JButton();
        openItem = new javax.swing.JButton();
        newMeasureLabel = new javax.swing.JLabel();
        openMeasureLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("cz/cvut/fel/gfupan/res/Bundle"); // NOI18N
        setTitle(bundle.getString("StartupWindow.title")); // NOI18N
        setAlwaysOnTop(true);
        setModalExclusionType(null);
        setModalityType(null);
        setResizable(false);

        newItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/cvut/fel/gfupan/res/64/new.png"))); // NOI18N
        newItem.setBorderPainted(false);
        newItem.setContentAreaFilled(false);

        openItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/cvut/fel/gfupan/res/64/open.png"))); // NOI18N
        openItem.setBorderPainted(false);
        openItem.setContentAreaFilled(false);

        newMeasureLabel.setText(bundle.getString("StartupWindow.newMeasureLabel.text")); // NOI18N

        openMeasureLabel.setText(bundle.getString("StartupWindow.openMeasureLabel.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(newItem)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(newMeasureLabel)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(openItem)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(openMeasureLabel)))
                .addGap(0, 0, 0))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(newItem)
                    .addComponent(openItem))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(newMeasureLabel)
                    .addComponent(openMeasureLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleParent(null);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton newItem;
    private javax.swing.JLabel newMeasureLabel;
    private javax.swing.JButton openItem;
    private javax.swing.JLabel openMeasureLabel;
    // End of variables declaration//GEN-END:variables
}
